package permission

import (
	"HeadLineNews/proto_models/common"
	models "HeadLineNews/proto_models/manage/permission_model"
	"HeadLineNews/utils"
	"github.com/gin-gonic/gin"
)

type Ctx interface {
	ParseParamAddGroup(c *gin.Context) (p *models.RequestAddGroup, err error)
	ParseParamListGroup(c *gin.Context) (p *common.PageSize, err error)
	ParseParamListPerms(c *gin.Context) (p *common.PageSize, err error)

	ParseParamAddPermToGroup(c *gin.Context) (p *models.RequestAddPermToGroup, err error)
	ParseParamUpdatePermToGroup(c *gin.Context) (p *models.RequestUpdatePermToGroup, err error)
	ParseParamListGroupPerms(c *gin.Context) (p *models.RequestListGroupPerms, err error)

	ParseParamAddAdminToGroup(c *gin.Context) (p *models.RequestAddAdminToGroup, err error)
	ParseParamUpdateAdminToGroup(c *gin.Context) (p *models.RequestUpdateAdminToGroup, err error)
	ParseParamListGroupAdmins(c *gin.Context) (p *models.RequestListGroupAdmins, err error)
}

type ctx struct {
}

func NewCtx() Ctx {
	return &ctx{}
}

// ParseParamAddGroup 解析新增群组的参数
func (ctx *ctx) ParseParamAddGroup(c *gin.Context) (p *models.RequestAddGroup, err error) {
	p = new(models.RequestAddGroup)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamListGroup 解析查看群组的参数
func (ctx *ctx) ParseParamListGroup(c *gin.Context) (p *common.PageSize, err error) {
	p = new(common.PageSize)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamListPerms 解析查看权限的参数
func (ctx *ctx) ParseParamListPerms(c *gin.Context) (p *common.PageSize, err error) {
	p = new(common.PageSize)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamAddPermToGroup 解析将权限添加进群组的参数
func (ctx *ctx) ParseParamAddPermToGroup(c *gin.Context) (p *models.RequestAddPermToGroup, err error) {
	p = new(models.RequestAddPermToGroup)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamUpdatePermToGroup 解析更新群组权限的参数
func (ctx *ctx) ParseParamUpdatePermToGroup(c *gin.Context) (p *models.RequestUpdatePermToGroup, err error) {
	p = new(models.RequestUpdatePermToGroup)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamListGroupPerms 解析查看群组权限的参数
func (ctx *ctx) ParseParamListGroupPerms(c *gin.Context) (p *models.RequestListGroupPerms, err error) {
	p = new(models.RequestListGroupPerms)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamAddAdminToGroup 解析将管理员添加进群组的参数
func (ctx *ctx) ParseParamAddAdminToGroup(c *gin.Context) (p *models.RequestAddAdminToGroup, err error) {
	p = new(models.RequestAddAdminToGroup)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamUpdateAdminToGroup 解析更新群组管理员的参数
func (ctx *ctx) ParseParamUpdateAdminToGroup(c *gin.Context) (p *models.RequestUpdateAdminToGroup, err error) {
	p = new(models.RequestUpdateAdminToGroup)
	err = utils.ShouldBindProtobuf(c, p)
	return
}

// ParseParamListGroupAdmins 解析查看群组管理员的参数
func (ctx *ctx) ParseParamListGroupAdmins(c *gin.Context) (p *models.RequestListGroupAdmins, err error) {
	p = new(models.RequestListGroupAdmins)
	err = utils.ShouldBindProtobuf(c, p)
	return
}